package com.ctg.platform.core.security.entity;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;

import com.googlecode.jsonplugin.annotations.JSON;

public class Resource implements Serializable{
	private static final long serialVersionUID = -5595892137756141725L;

	private String id;
	
	private String type;
	
	private String displayName;
	
	private String value;
	
	private String productType;
	
	private String disabled;
	
	private List < Role > roles;
	
	/**
	 * The default constructor
	 */
	public Resource() {
		
	}
	
    /**
     * Get role authorities as string
     * 
     * @return
     */
	@JSON(serialize = false)
	public String getRoleAuthorities() {
    	List < String > roleAuthorities = new ArrayList < String > ();
    	for ( Role role : roles ) {
    		roleAuthorities.add(role.getName());
    	}
        return StringUtils.join(roleAuthorities, ",");
    }

	/**
	 * @return the id
	 */
	public String getId() {
		return id;
	}

	/**
	 * @return the type
	 */
	public String getType() {
		return type;
	}

	/**
	 * @return the value
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @return the roles
	 */
	@JSON(serialize = false)
	public List < Role > getRoles() {
		return roles;
	}

	/**
	 * @param id the id to set
	 */
	public void setId(String id) {
		this.id = id;
	}

	/**
	 * @param type the type to set
	 */
	public void setType(String type) {
		this.type = type;
	}

	/**
	 * @param value the value to set
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * @param roles the roles to set
	 */
	public void setRoles(List < Role > roles) {
		this.roles = roles;
	}

	/**
	 * @return ��ȡproductType
	 */
	public String getProductType() {
		return productType;
	}

	/**
	 * @param productType ����productType
	 */
	public void setProductType(String productType) {
		this.productType = productType;
	}

	/**
	 * @return ��ȡdisabled
	 */
	public String getDisabled() {
		return disabled;
	}

	/**
	 * @param disabled ����disabled
	 */
	public void setDisabled(String disabled) {
		this.disabled = disabled;
	}

	/**
	 * @return 返回displayName
	 */
	public String getDisplayName() {
		return displayName;
	}

	/**
	 * @param displayName 设置displayName
	 */
	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}

}
